﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Text.RegularExpressions;

namespace ProjectSem3
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        private dataDataContext dc = new dataDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ButtonSignin_Click(object sender, EventArgs e)
        {
            Customer cus = new Customer();
            cus.Username = this.TextBoxUsername.Text;
            cus.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBoxPassword.Text, "sha1");
            cus.Name = this.TextBoxName.Text;
            cus.BirthDay = Convert.ToDateTime(this.TextBoxBirthday.Text);
            foreach (ListItem l in RadioButtonListGender.Items)
            {

                if (l.Selected)
                {
                    if (l.Text.Equals("Male"))
                        cus.Gender = true;
                    else
                        cus.Gender = false;
                }
            }
            cus.Email = this.TextBoxEmail.Text;
            cus.Address = this.TextBoxAddress.Text;
            cus.CompanyAddress = this.TextBoxComAddress.Text;
            cus.Phone = this.TextBoxPhone.Text;
            cus.Status = false;
            cus.RoleCusID = 3;
            this.dc.Customers.InsertOnSubmit(cus);
            this.dc.SubmitChanges();
            Response.Redirect("default.aspx");
        }
    }
}